package com.hishop.common;

import com.google.common.collect.Sets;

import java.util.Set;

/**
 * 定义常量类
 * Created by hejie on 2017/7/14.
 */
public final class Constant {
    public static final String NO_USER="用户名不存在";
    public static final String HAVE_USER="用户名已存在";
    public static final String HAVE_EMAIL="email已存在";
    public static final String REGISTER_FAIL="注册失败";
    public static final String REGISTER_SUCCESS="注册成功";
    public static final String CHECK_VALID_SUCCESS="校验成功";
    public static final String PWD_ERROR="密码错误";
    public static final String PWD_UPDATE_SUCCESS="密码更新成功";
    public static final String PWD_UPDATE_FAIL="密码更新失败";
    public static final String ARG_ERROR="参数错误";
    public static final String LOGIN_ERROR="用户未登录，无法获取当前用户的信息";
    public static final String QUESTION_BLANK="找回密码的问题是空的";
    public static final String QUESTION_ANSWER_ERROR="问题的答案错误";
    public static final String TOKEN_ARG_ERROR="参数错误，token需要传递";
    public static final String TOKEN_EXPIRE="token无效或者过期";
    public static final String UPDATE_PASSWORD_SUCCESS="修改密码成功";
    public static final String UPDATE_PASSWORD_FAIL="修改密码失败";
    public static final String TOKEN_ERROR="token错误，请重新获取重置密码的token";
    public static final String CURRENT_USER="currentUser";
    public static final String USERNAME="username";
    public static final String EMAIL="email";
    public interface Role{
        int ROLE_CUSTOMER=0;
        int ROLE_ADMIN=1;
    }
    public enum productStatusEnum{
        ON_SALE(1,"在线");
        private String value;
        private int code;
        productStatusEnum(int code,String value){
            this.code=code;
            this.value=value;
        }

        public int getCode() {
            return code;
        }

        public String getValue() {
            return value;
        }
    }

    public interface productListOrderBy{
        Set<String> PRICE_ASC_DESC= Sets.newHashSet("price_desc","price_asc");
    }

    public interface Cart{
        int CHECKED = 1;//选中
        int UN_CHECKED=0;//未选中
        String LIMIT_NUM_FAIL="LIMIT_NUM_FAIL";
        String LIMIT_NUM_SUCCESS="LIMIT_NUM_SUCCESS";
    }

    public enum OrderStatusEnum{
        CANCELED(0,"已取消"),
        NO_PAY(10,"未支付"),
        PAID(20,"已付款"),
        SHIPPED(40,"已发货"),
        ORDER_SUCCESS(50,"订单完成"),
        ORDER_CLOSE(60,"订单关闭");

        private String value;
        private int code;
        public String getValue() {
            return value;
        }
        public int getCode() {
            return code;
        }

        OrderStatusEnum(int code,String value){
            this.code=code;
            this.value=value;
        }

        public static String codeOf(int code){
            for (OrderStatusEnum orderStatusEnum :values()){
                if (orderStatusEnum.getCode() == code){
                    return orderStatusEnum.getValue();
                }
            }
            throw new RuntimeException("没有找到对应的枚举值");
        }
    }
    public enum PaymentTypeEnum{
        ONLINE_PAY(1,"在线支付"),
        DELIVERY_PAY(2,"货到付款");

        private String value;
        private int code;
        public String getValue() {
            return value;
        }
        public int getCode() {
            return code;
        }
        PaymentTypeEnum(int code,String value){
            this.code=code;
            this.value=value;
        }

        public static String codeOf(int code){
            for (PaymentTypeEnum paymentTypeEnum :values()){
                if (paymentTypeEnum.getCode() == code){
                    return paymentTypeEnum.getValue();
                }
            }
            throw new RuntimeException("没有找到对应的枚举值");
        }
    }


    public interface AlipayCallback{
        String TRADE_STATUS_WAIT_BUYER_PAY = "WAIT_BUYER_PAY";
        String TRADE_STATUS_TRADE_SUCCESS = "TRADE_SUCCESS";

        String RESPONSE_SUCCESS = "success";
        String RESPONSE_FAILED = "failed";
    }

    public enum PayPlatformEnum{
        ALI_PAY(1,"支付宝"),
        WX_PAY(2,"微信支付");

        private String value;
        private int code;
        public String getValue() {
            return value;
        }
        public int getCode() {
            return code;
        }
        PayPlatformEnum(int code,String value){
            this.code=code;
            this.value=value;
        }
    }

    public interface RedisCacheExtime{
        int REDIS_SESSION_EXTIME = 60*30;//30分钟
    }

    public interface RedisLock{
        String CLOSE_ORDER_TASK_LOCK = "CLOSE:ORDER:TASK:LOCK";//关闭订单分布式锁
    }
}
